package com.yijiaganxi.product.web.product;

import com.yijiaganxi.product.openFeign.TestOpenFeign;
import com.yijiaganxi.product.service.product.YjgxProductService;
import io.seata.spring.annotation.GlobalTransactional;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.bind.annotation.*;
import org.yijiaganxi.common.GlobalConstants;
import org.yijiaganxi.common.entity.banner.YjgxBanner;
import org.yijiaganxi.common.entity.product.YjgxProduct;
import org.yijiaganxi.common.res.R;

import java.math.BigDecimal;
import java.util.Date;

@RestController
@RequestMapping("/product")
public class TestController {

    @Autowired
    private TestOpenFeign testOpenFeign;

    @GetMapping("queryTestGet1")
    public Object queryTestGet1() {
        return testOpenFeign.queryTestGet1();
    }

    @GetMapping("queryTestGet2")
    public YjgxBanner queryTestGet2() {
        return testOpenFeign.queryTestGet2();
    }

    @GetMapping("queryTestGet3")
    public Object queryTestGet3(String id) {
        return testOpenFeign.queryTestGet3(id);
    }

    @GetMapping("queryTestGet4")
    public YjgxBanner queryTestGet4(String id) {
        return testOpenFeign.queryTestGet4(id);
    }

    @GetMapping("queryTestGet5")
    public YjgxBanner queryTestGet5(YjgxBanner banner) {
        return testOpenFeign.queryTestGet5(banner);
    }

    @GetMapping("testTimeOut")
    public R testTimeOut() throws InterruptedException {
        Thread.sleep(65000);
        return R.error();
    }


    @PostMapping("queryTestPost1")
    public Object queryTestPost1() {
        return testOpenFeign.queryTestPost1();
    }

    @PostMapping("queryTestPost2")
    public YjgxBanner queryTestPost2() {
        return testOpenFeign.queryTestPost2();
    }

    @PostMapping("queryTestPost3")
    public Object queryTestPost3(String id) {
        return testOpenFeign.queryTestPost3(id);
    }

    @PostMapping("queryTestPost4")
    public YjgxBanner queryTestPost4(String id) {
        return testOpenFeign.queryTestPost4(id);
    }

    @PostMapping("queryTestPost5")
    public R queryTestPost5(YjgxBanner banner) {
        return testOpenFeign.queryTestPost5(banner);
    }

    @Autowired
    private YjgxProductService productService;


    @GetMapping("testTransaction1")
    public R testTransaction1(Integer i) {
        return R.ok(productService.test(i).toString());
    }
}
